<?php
//解决中文乱码问题
// header('content-type:text/html;charset=utf-8')
// header("Access-Control-Allow-Origin: *");    // 如果客户端和服务端不同域，要加上这行代码，不然会报跨域错误
// header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Content-type: application/json");
//跨域
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Origin: *");
//CORS
header("Access-Control-Request-Methods:GET, POST, PUT, DELETE, OPTIONS");
header('Access-Control-Allow-Headers:x-requested-with,content-type,test-token,test-sessid');
//$params=json_decode(file_get_contents("php://input"),true);/
//接收前端传过来的值
 //$username=$params['id']
// $userpwd=$params['pwd']
// $username=$_POST['id'];
// $userpwd=$_POST['pwd'];
//echo($username);
//echo($userpwd);
//连接数据库
$conn=mysqli_connect('127.0.0.1','root','root','erp');

//在注册前先查找本账号有没有被注册
$sql1="select username from userinformation where username='$username'";
$res1=mysqli_query($coon,$sql1);
//进行转换
$data=mysqli_fetch_all($res1,MYSQLI_ASSOC);
if($data){
    echo('本账号已被注册');
}else{
    //执行操作
$sql='insert into `userinformation` values(null,111,111)';
$res=mysqli_query($coon,$sql);
alert('注册成功');
}
mysqli_close($conn);


?>